﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using YNCNumberSys.DbDal;

namespace YNCNumberSys
{
    public partial class StatisticsForm : Form
    {
        Thread m_thread;
        public StatisticsForm()
        {
            InitializeComponent();
        }

        void statistics()
        {
            DateTime t1 = DateTime.Now;
            statisticsDal dal = new statisticsDal();
            DataTable dt = dal.statistics();
            if (dt != null)
                m_flex.DataSource = dt;
            m_flex.AutoSizeCols();
            //this.loading21.Visible = false;
            this.panel1.Visible = false;
            DateTime t2 = DateTime.Now;
            TimeSpan tPan = t2 - t1;
            this.label2.Text = string.Format("耗时{0}h{1}m{2}.{3}s，", tPan.Hours, tPan.Minutes, tPan.Seconds, t1.Millisecond) + "共计:" + dt.Rows.Count+ "系列。";
            
        }
        private void StatisticsForm_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            m_thread = new Thread(new ThreadStart(statistics));
             m_thread.Start();
        }

        private void StatisticsForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            m_thread.Abort();
            this.Close();
        }
    }
}
